void function(n){
    var win = window, undefined, NS = (n in win) ? win[n] : (win[n] = {
        'Config' : {
			'DATA_LASTMODIFIED' : 9998887776,
			'SKIN_LASTMODIFIED' : 20101201,
			'PAGE_LASTMODIFIED' : 20101201,
			'SCRIPT_LASTMODIFIED' : 20101201
        },'ready' : false
        }),
        btnList = {
		'sd:login-button' : {
			'mode' : 'script',
			'alt' : '连接盛大通行证',
			'ico' : 'http://x.res.ibw.staticsdo.com/connect/images/login_{$size}_{$color}.jpg',
            'defValue' : {
                'size' : '1',
                'color' : 'blue'
            },
            'event' : 'onclick',
			'script' :  function(){
                NS.Connect();
            }
		},
		'sd:pay-button' : {
			'mode' : 'script',
			'alt' : '盛大充值',
			'ico' : 'http://x.res.ibw.staticsdo.com/connect/images/pay_{$size}_{$color}.jpg',
            'defValue' : {
                'size' : '1',
                'color' : 'blue'
            },
            'event' : 'onclick',
			'script' :  function(){
                __IBW__.Authorize.check(function(){
                    if(NS.ready)
                    {
                        __IBW__.openWidget('sdoNewPay');
                        NS.logSend('openWidget',NS.Config.SPID,'sdoNewPay');
                    }
                });
               NS.logSend('openWidget',NS.Config.SPID,'sdoNewPay');
            }
		},
		'sd:invite-button' : {
			'mode' : 'script',
			'alt' : '邀请好友',
			'ico' : 'http://x.res.ibw.staticsdo.com/connect/images/invite_{$size}_{$color}.jpg',
            'defValue' : {
                'size' : '1',
                'color' : 'blue'
            },
            'event' : 'onclick',
			'script' :  function(){
                            __IBW__.Authorize.check(function(){
                                __IBW__.openWidget('sdoInviteFriend');
                                NS.logSend('openWidget',NS.Config.SPID,'sdoInviteFriend');
                            });
                            NS.logSend('clickButton',NS.Config.SPID,'sdoInviteFriend');
                        }
		},
		'sd:like-button' : {
			'mode' : 'iframe',
			'url' : 'http://api.connect.open.sdo.com/like?appid={$appid}&size={$size}&color={$color}&title={$title}&link={$link}&type={$type}&pic={$pic}&desc={$desc}&counter={$counter}&data={$data}'
		},
		'sd:share-button' : {
			'mode' : 'share',
            'ico' : 'http://x.res.ibw.staticsdo.com/connect/images/share_{$size}_{$color}.jpg'
		}
	},
    logURL = 'http://log.ibw.sdo.com/connect.jpg',pv = true;
    
    NS.Authorize = {};
    NS.Authorize.check = function(){};
    NS.Connect = function(){
        if(NS.ready)
        {
            NS.Authorize.localConnect = true;
            NS.Authorize.check();
        }
    };
    
    NS.logSend = function(c,a,w,p){
        var _url = logURL + '?action=' + c;
        if(typeof a != 'undefined'){
            _url = _url + '&appid=' + a;
        }
        
        if(typeof w != 'undefined'){
            _url = _url + '&widget=' + w;
        }
        
        if(typeof p != 'undefined'){
            _url = _url + '&pt=' + p;
        }
        (new Image()).src = _url;
    };
    
    function replaceflg(s,list,def)
    {
        list = list || {};
        def = def || {};
        for(var i in list)
        {
            s = s.replace(/{\$(\w+)}/ig,function(a,b){
                if(list[b] != null)
                {
                    return list[b];
                }else if(def[b] != null){
                    return def[b];
                }else{
                    return '';
                }
            });
        }
        return s;
    }
    
    function replaceNode(s)
    {
        var node = document.getElementsByTagName(s),span,showType,link,size,color,l=node.length;
        if(l<1) return false;
        for(var i = 0; i < l; i++)
        {
            span = document.createElement('span');
            span.className = '__ibwConnectButton__';
            span.style.cssText = 'display:inline-block;*zoom:1;*display:inline';
            node[i].parentNode.insertBefore(span,node[i]);
            
            showType = node[i].getAttribute('data-type');
            showDesc = node[i].getAttribute('data-desc');
            sdowPic = node[i].getAttribute('data-pic');
            link  = node[i].getAttribute('data-url');
            size = node[i].getAttribute('size');
            color = node[i].getAttribute('color');
            
            if(link && (link != ''))
            {
                link = encodeURIComponent(link);
            }else{
                link = encodeURIComponent(document.location.href);
            }
            
            switch(btnList[s]['mode'])
            {
                case 'script' :
                    switch(showType)
                    {
                        case 'icon':
                            var val = node[i].getAttribute('data-text') || btnList[s]['alt'];
                            span.className = 'sd_Link_icon __ibwConnectButton__';
                            span.innerHTML = val;
                            span.style.cssText = 'cursor:pointer; padding-left:20px; background:url("http://x.res.ibw.staticsdo.com/connect/images/icon_1.gif") no-repeat scroll 0 0 transparent; height:16px; font-size:12px; line-height:16px; display:inline-block; *zoom:1; *display:inline'
                            span.style.color = node[i].getAttribute('color') || '#005EAC';
                            span[btnList[s]['event']] = btnList[s]['script'];
                            break;
                        default :
                            url = replaceflg(btnList[s]['ico'],{
                                'size' : size,
                                'color' : color
                            },btnList[s]['defValue']);
                            span.innerHTML = '<img src="' + url + '" alt="' + btnList[s]['alt'] + '" style="border:0;cursor:pointer;" />';
                            span[btnList[s]['event']] = btnList[s]['script'];
                    }
                    break;
                case 'iframe' :
                    url = replaceflg(btnList[s]['url'],{
                            'appid': NS.Config.SPID,
                            'data' : i,
                            'size' : size,
                            'color' : encodeURIComponent(color||''),
                            'link' : link,
                            'title' : encodeURIComponent(node[i].getAttribute('title')||document.title),
                            'desc' : encodeURIComponent(node[i].getAttribute('desc')||''),
                            'type' : encodeURIComponent(node[i].getAttribute('type')||''),
                            'pic' : encodeURIComponent(node[i].getAttribute('pic')||'')
                    });
                    span.style.display = 'none';
                    ifm = [NS.Domain.create(url,span,'__sdoLikeThisSite'+i+'__')];
                    ifm[0].style.position = 'relative';
                    ifm[0].setAttribute('id','__sdoLikeThisSite'+i+'__');
                    ifm[0].setAttribute('frameborder','0');
                    switch(Number(size)){
                        case 1:
                            ifm[0].setAttribute('width',130);
                            ifm[0].setAttribute('height',20);
                            break;
                        case 2:
                            ifm[0].setAttribute('width',155);
                            ifm[0].setAttribute('height',26);
                            break;
                    }
                    span.setAttribute('data-id',i);
                    span.style.cssText = 'vertical-align: middle;display:inline-block;*zoom:1;*display:inline';

                    span.style.cursor = 'pointer';
                    span.onclick = function(){
                        var i = this.getAttribute('data-id');
                        __IBW__.Authorize.check(function(){
                            NS.Domain.call({
                                namespace : 'NS___sdoLikeThisSite'+i+'__',
                                fn : 'likeThisSite'
                            });
                        });
                    }
                    ifm[0].style.zIndex = -1;
                    break;
                case 'share' :
                    showType = showType || 'button';
                    showDesc = showDesc || 'top';
                    switch(showType)
                    {
                        case 'icon' :
                        case 'side' :
                            (function(a,b){
                                window['SdoShareInit'] = function(c){
                                    c.side = a;
                                    c.triggerColor = b;
                                };
                            })(showDesc,color);
                            NS.Tool.DOM.loadJS('http://feo.staticsdo.com/js/import/http%253A%252F%252Fx.res.ibw.staticsdo.com%252Fconnect%252Fshare%252Fside.xml/v20110113/debug/share.js');
                            break;
                        default :
                            if(sdowPic)
                            {
                                 span.innerHTML = '<img id="sdo_share_button" src="' + sdowPic + '" data-desc="' + showDesc + '" />';
                            }else{
                                url = replaceflg(btnList[s]['ico'],{
                                    'size' : size,
                                    'color' : color
                                });
                                span.innerHTML = '<img id="sdo_share_button" src="' + url + '" data-desc="' + showDesc + '" style="border:0;cursor:pointer;" />';
                            }
                            NS.Tool.DOM.loadJS('http://feo.staticsdo.com/js/import/http%253A%252F%252Fx.res.ibw.staticsdo.com%252Fconnect%252Fshare%252Fbutton.xml/v20110113/debug/share.js');
                    }
                    break;
            }
        }
        while(node.length){
            node[0].parentNode.removeChild(node[0]);
        }
        node = document.getElementsByTagName('/'+s);
        while(node.length){
            node[0].parentNode.removeChild(node[0]);
        }
        return true;
    }

    if('ibwSpInit' in win)
    {
        ibw = {};
        ibwSpInit();
        win['IBWINIT'] = function(){
            this.SPID = ibw.appid || 0;
            this.useSNDA = ibw.useSDOLogin;
            this.EVENT.ready = function(){
                for(var i in btnList) replaceNode(i);
                if(pv){
                    pv = false;
                    NS.logSend('pv',NS.Config.SPID);
                }
            };
            this.EVENT.loginStatus = function(s){
                if(typeof ibw.loginStatus == 'function'){
                    ibw.loginStatus(s);
                }
                var nodeList = __IBW__.Tool.DOM.$C('__ibwConnectButton__','span'),len=nodeList.length;
                for(j = 0; j < len; j++)
                {
                    ifm = nodeList[j].getElementsByTagName('iframe');
                    for(i=0,l=ifm.length;i<l;i++)
                    {
                        ifm[i].src = ifm[i].src;
                    }
                }
            }
        } 
    }
    replaceNode('sd:login-button');
    replaceNode('sd:pay-button');
}('__IBW__');

void function(n){
	var win = window, undefined, NS = (n in win) ? win[n] : (win[n] = {}),
		fileName = 'ibw',
		hash = win.location.hash,
		site = {},
		version = {'v0': { p :0, n : 'http://feo.staticsdo.com/js/import/http%253A%252F%252Fx.res.ibw.staticsdo.com%252Fconnect%252Fapi%252F1.0.0.0%252Fxml%252Fconfig.xml/', o :'http://feo.staticsdo.com/js/import/http%253A%252F%252Fx.res.ibw.staticsdo.com%252Fconnect%252Fapi%252F1.0.0.0%252Fxml%252Fconfig.xml/'}},
		setCookie = function(n,v,t){
			document.cookie = n + "=" + encodeURIComponent(v) + (t ? "; expires=" + new Date(new Date().getTime()+(1000*60*60*24*t)).toGMTString() : "");
		},
		getCookie = function(n){
			var r;return (r = new RegExp('(?:; )?' + n + '=([^;]*);?', 'g').exec(document.cookie)) ? decodeURIComponent(r[1]) : null;
		},
		loadIBW = function(u,c){
			var el = document.createElement('script');
			el.charset = c || 'utf-8';
			el.src = u + fileName + '.js';
			document.getElementsByTagName('head')[0].appendChild(el);
		},
		h = win.location.host.toLowerCase(), v = version['v0'], u, spInfo = {EVENT:{}};
		
		for(var i = 0, l = h.split('.').length; i < l; i++){
			if(site[h]){
				if(!i||!site[h].b)
				{
					v = version['v' +site[h].a];
					break;
				}
			}
			h = h.substr(h.indexOf('.')+1);
		}
		u = getCookie('IBW_UserRandom');
		u == null && (u = Math.random() * 100);
		hash=='#IBWTEST' && (u = 0);
		setCookie('IBW_UserRandom', u, 30);
		'IBWINIT' in win && IBWINIT.call(spInfo);
		loadIBW((u > v.p ? v.o : v.n).replace(/{\$SPID}/,spInfo.SPID));
}('__IBW__');